<?php
/**
 * 额外的输出错误到csv操作，这里调用了errorObject的新方法，需要启动adapter模式
 * Created by PhpStorm.
 * User: liangtiehui
 * Date: 2015/12/22
 * Time: 22:50
 */
namespace Adapter;

class LogToCsv
{
    const CSV_LOCATION = 'log.csv';

    private $_errorObject;

    public function __construct($errorObject)
    {
        $this->_errorObject = $errorObject;
    }

    public function write()
    {
        $line = $this->_errorObject->getErrorNum();
        $line .= ",";
        $line .= $this->_errorObject->getErrorText();
        $line .= "\n";

        file_put_contents(self::CSV_LOCATION, $line, FILE_APPEND);
    }
}